package entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Embeddable
public class NotificationPK implements Serializable {
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "eventId")
    private int eventId;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "participantUsername")
    private String participantUsername;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "timestamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestamp;

    public NotificationPK() {
    }

    public NotificationPK(int eventId, String participantUsername, Date timestamp) {
        this.eventId = eventId;
        this.participantUsername = participantUsername;
        this.timestamp = timestamp;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public String getParticipantUsername() {
        return participantUsername;
    }

    public void setParticipantUsername(String participantUsername) {
        this.participantUsername = participantUsername;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) eventId;
        hash += (participantUsername != null ? participantUsername.hashCode() : 0);
        hash += (timestamp != null ? timestamp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof NotificationPK)) {
            return false;
        }
        NotificationPK other = (NotificationPK) object;
        if (this.eventId != other.eventId) {
            return false;
        }
        if (!Objects.equals(this.participantUsername, other.participantUsername)) {
            return false;
        }
        return Objects.equals(this.timestamp, other.timestamp);
    }

    @Override
    public String toString() {
        return "entity.NotificationPK[ eventId=" + eventId + ", participantUsername=" + participantUsername + ", timestamp=" + timestamp + " ]";
    }
    
}
